# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper

  def my_fensies
    Follow.find_all_by_idol_id current_user.id
  end

  def my_idols
    Follow.find_all_by_fensi_id current_user.id
  end

  def status_time_ago_in_words(time)
    time_word = time_ago_in_words(time)
    case time_word
    when "less than a minute"
      "刚刚"
    when /minute/
      time_word.gsub(/minutes|minute/,'分钟') + "前"
    when /hour/
      ##time.gsub(/about/,'').gsub(/hours/,'小时') + "前"
      time_word.gsub(/about (\d+) (hours|hour)/, '\1小时') + "前后"
    when "1 day"
      "昨天"
    when "2 days"
      "前天"
    when "3 days"
      "3天前"
    else
      time.strftime("%Y年%m月%d %H:%M")
    end
  end

  def is_current(user)
    current_user == user
  end

  def is_not_my_favorite(user,weibo)
    follow = Favorite.find_by_user_id_and_weibo_id(user.id,weibo.id)
    follow==nil
  end

end
